package com.atguigu.mq.listener;

import com.atguigu.mq.constant.PunchConst;
import com.atguigu.mq.service.PunchClockService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author KEIO  on 2021/9/5.
 * @version 1.0
 */
@Slf4j
@Component
public class PunchListener {


    @Autowired
    PunchClockService punchClockService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = PunchConst.QUEUE_TASK_8, durable = "true"),
            exchange = @Exchange(value = PunchConst.EXCHANGE_DIRECT_TASK),
            key = {PunchConst.ROUTING_TASK_8}
    ))
    void punchClock(Message message, Channel channel){


        log.info("收到消息了");
        punchClockService.punchClockRightNow();

    }


}
